package com.smartwasser.yunhtgl.apphtgl.activity;

import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
import android.widget.TextView;

import com.smartwasser.yunhtgl.apphtgl.R;
import com.smartwasser.yunhtgl.apphtgl.base.BaseActivity;
import com.smartwasser.yunhtgl.apphtgl.base.BaseSpinner;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

import static android.view.View.inflate;
import static com.smartwasser.yunhtgl.apphtgl.R.id.upSeason1;

/**
 * 备案
 */
public class SealActivity extends BaseActivity {
    @BindView(R.id.tv_toolbar)
    TextView tv_toolbar;
    @BindView(R.id.spinner1)
    Spinner spinner1;

    @Override
    public void setContentLayout() {
        setContentView(R.layout.activity_seal);
        ButterKnife.bind(this);
    }

    @Override
    public void initView() {
        tv_toolbar.setText("用印备案上传");
        initSpinner();
    }

    @Override
    public void initData() {

    }

    @OnClick({R.id.back, upSeason1, R.id.upSeason2, R.id.upSeason3, R.id.upSeason4,
            R.id.seeSeason1, R.id.seeSeason2, R.id.seeSeason3, R.id.seeSeason4})
    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.back:
                finish();
                break;
            case R.id.upSeason1:
                startActivity(SealLoadActivity.class, "SealLoad", "upSeason1");
                break;
            case R.id.upSeason2:
                startActivity(SealLoadActivity.class, "SealLoad", "upSeason2");
                break;
            case R.id.upSeason3:
                startActivity(SealLoadActivity.class, "SealLoad", "upSeason3");
                break;
            case R.id.upSeason4:
                startActivity(SealLoadActivity.class, "SealLoad", "upSeason4");
                break;
            case R.id.seeSeason1:
                startActivity(SealSeeActivity.class, "SealSee", "seeSeason1");
                break;
            case R.id.seeSeason2:
                startActivity(SealSeeActivity.class, "SealSee", "seeSeason2");
                break;
            case R.id.seeSeason3:
                startActivity(SealSeeActivity.class, "SealSee", "seeSeason3");
                break;
            case R.id.seeSeason4:
                startActivity(SealSeeActivity.class, "SealSee", "seeSeason4");
                break;
        }
    }

    private void initSpinner() {
        final List<String> arrayList1 = new ArrayList<>();
        arrayList1.add("2017");
        arrayList1.add("2016");
        arrayList1.add("2015");

        ArrayAdapter<String> adapter1 = new ArrayAdapter<String>(this,
                R.layout.spinner_drop, arrayList1) {
            @Override
            public View getDropDownView(int position, View convertView, ViewGroup parent) {
                View view = inflate(getContext(), R.layout.spinner_item_layout, null);
                TextView label = view.findViewById(R.id.spinner_item_label);
                label.setText(arrayList1.get(position));
                if (spinner1.getSelectedItemPosition() == position) {
                    label.setTextColor(getResources().getColor(R.color.colorTitle));
                } else {
                    label.setTextColor(getResources().getColor(R.color.colorText));
                }

                return view;
            }
        };
        adapter1.setDropDownViewResource(R.layout.spinner_item_layout);
        spinner1.setAdapter(adapter1);
        spinner1.setSelection(0, true);
        spinner1.setOnItemSelectedListener(new BaseSpinner() {
            @Override
            public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {

            }
        });
    }
}
